<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>编辑小区</title>
    <#assign base=request.contextPath  />
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <link rel="stylesheet" type="text/css" href="${base}/backstage/iconfont.css"/>
    <link rel="stylesheet" href="${base}/frame/layui/css/layui.css?t=1534970980648" media="all">
    <script src="${base}/frame/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${base}/js/zhang.js"></script>
    <script src="${base}/js/jquery.min.js"></script>
    <style type="text/css">
        form {
            padding: 10px;
        }
        .layui-btn-radius {
            border-radius: 3px;
        }
    </style>
</head>
<body>
<form class="layui-form">

    <input type="hidden" id="id" />

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">小区名称</label>
            <div class="layui-input-inline">
                <input name="quartersName" id="quartersName" lay-verify="required" autocomplete="off" class="layui-input" type="text">
            </div>
        </div>
    </div>

    <div class="layui-form-item" style="margin-left: 30px">
        <div class="layui-input-inline">
            <button class="layui-btn" lay-submit lay-filter="formDemo" lay-submit="" type="button"
                    id="onInsert" style="background-color: #0092EF;">立即提交
            </button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
    </div>
</form>



<script>



    layui.use(['form', 'layedit', 'laydate', 'layer', 'upload' ], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;
        var $ = layui.jquery
                ,upload = layui.upload;



    });

    //添加
    $("#onInsert").one("click",function(){
        if ($("#quartersName").val() == "") {
            layer.msg("小区名称不能为空")
            return;
        }
        var jsonDate = {
            quartersName: $("#quartersName").val(),
            id: $("#id").val(),
        };
        $.ajax({
            type: "POST", //提交方式
            contentType: "application/json;charset=UTF-8",
            url: "${base}/admin/quarters/updateByIdQuarters",//路径
            data: JSON.stringify(jsonDate),
            success: function (data) {//返回数据根据结果进行相应的处理
                if (data.code === 0) {
                    layer.msg(data.msg);
                    setTimeout(function () {
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    }, 500)
                    var table = parent.layui.table;
                    //表刷新方法
                    table.reload('testReload', {
                        url: '${base}/admin/quarters/selectMyPage'
                        , where: {} //设定异步数据接口的额外参数
                        //,height: 300
                    });
                } else {
                    layer.msg(data.msg)
                }
            }
        });
    })
</script>




</body>
</html>
